package com.rahwi.rahwi_server.Controller;


import com.rahwi.rahwi_server.Handler.Security.Security;
import com.rahwi.rahwi_server.Service.impl.CommentService;
import com.rahwi.rahwi_server.Service.impl.PostDetailService;
import com.rahwi.rahwi_server.vo.params.*;
import com.rahwi.rahwi_server.vo.results.ActionResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName CommentController
 * @Description
 * @Date 2021/12/30 13:57
 * @Autor dn
 * @Version 1.0
 */

@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    CommentService commentService;

    @Security
    @PostMapping("/send")
    public ActionResult SendNewComment(@RequestBody CommentParam commentParam){
        return commentService.AddComment(commentParam.getUid(),commentParam.getPid(),commentParam.getPictures(),commentParam.getContent())?ActionResult.success("true"):ActionResult.fail(700,"回复失败");
    }

    @Security
    @PostMapping("/reply/tocomment")
    public ActionResult SendReplyToComment(@RequestBody ReplyToCommentParams replyToCommentParams){
        return commentService.ReplyToComment(replyToCommentParams.getCid(),replyToCommentParams.getUid(),replyToCommentParams.getContent())?ActionResult.success("true"):ActionResult.fail(700,"回复失败");
    }

    @Security
    @PostMapping("/reply/toreply")
    public ActionResult SendReplyToReply(@RequestBody ReplyToReplyParams replyToReplyParams){
        return commentService.ReplyToReply(replyToReplyParams.getCid(), replyToReplyParams.getUid(), replyToReplyParams.getRid(), replyToReplyParams.getContent())?ActionResult.success("true"):ActionResult.fail(700,"回复失败");
    }

}
